Fearless Refactoring and
the Art of Argument-Free Rust
Ed Jones, RustConf ’24
- I work at Canonical
- I like clean code
- I annoy my coworkers
industry’s hard problems
- requirements
- politics
- maintenance
what is maintainable?
- simple
- easily-understood
- predictable
for whom does the coder code?
for whom does the coder code?
- customers and consumers
- coworkers
- themselves
Fearless Refactoring
after making a change, the next time all tooling passes,
code likely still works as intended
good practices
- match exhaustively
- mutate in well-defined regions
- limit unsafety
good code
- predictable
- clear flow of concepts
- obvious responsilbilities
- sparingly weird
weird code
- draws the eye
- result of uncoordinated practices
- resolved by debate
The Art of Argument-free Rust
The Art of Argument-free Rust
note: not debate-free
how we’ve avoided arguments
how we’ve avoided arguments
- office hours (‘Rust Surgery’)
- cross-team code-review
- standardisation docs
standardisation docs
- provide a reference point for best-practices
- provide rationale for particular decisions
- show benefits with clear examples
the process
- note repeated arguments
- write up generally-applicable notes
- review with a few experienced Rustaceans
- review with many Rustaceans
- release
the process (hard-mode)
- note repeated arguments
- write up generally-applicable notes
- review with a few experienced Rustaceans
- review with many Rustaceans
- release
the process (easy-mode)
github.com/canonical/rust-best-practices